package org.msfj.admin.model;

import org.msfj.common.base.BaseModel;

import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;

@Table(name = "admin_log")
public class Log extends BaseModel implements Serializable {
    /**
     * 执行方法说明
     */
    @Column(name = "notes_")
    private String notes;

    /**
     * 执行的类跟方法
     */
    @Column(name = "method_")
    private String method;

    /**
     * 请求url
     */
    @Column(name = "request_url")
    private String requestUrl;

    /**
     * 用户id
     */
    @Column(name = "user_id")
    private String userId;

    /**
     * 请求参数
     */
    @Column(name = "params_")
    private String params;

    /**
     * 消耗时间  毫秒
     */
    @Column(name = "time_")
    private Long time;

    /**
     * 请求者ip地址
     */
    @Column(name = "ip_")
    private String ip;



    /**
     * 获取执行方法说明
     *
     * @return notes_ - 执行方法说明
     */
    public String getNotes() {
        return notes;
    }

    /**
     * 设置执行方法说明
     *
     * @param notes 执行方法说明
     */
    public void setNotes(String notes) {
        this.notes = notes == null ? null : notes.trim();
    }

    /**
     * 获取执行的类跟方法
     *
     * @return method_ - 执行的类跟方法
     */
    public String getMethod() {
        return method;
    }

    /**
     * 设置执行的类跟方法
     *
     * @param method 执行的类跟方法
     */
    public void setMethod(String method) {
        this.method = method == null ? null : method.trim();
    }

    /**
     * 获取请求url
     *
     * @return request_url - 请求url
     */
    public String getRequestUrl() {
        return requestUrl;
    }

    /**
     * 设置请求url
     *
     * @param requestUrl 请求url
     */
    public void setRequestUrl(String requestUrl) {
        this.requestUrl = requestUrl == null ? null : requestUrl.trim();
    }

    /**
     * 获取用户id
     *
     * @return user_id - 用户id
     */
    public String getUserId() {
        return userId;
    }

    /**
     * 设置用户id
     *
     * @param userId 用户id
     */
    public void setUserId(String userId) {
        this.userId = userId;
    }

    /**
     * 获取请求参数
     *
     * @return params_ - 请求参数
     */
    public String getParams() {
        return params;
    }

    /**
     * 设置请求参数
     *
     * @param params 请求参数
     */
    public void setParams(String params) {
        this.params = params == null ? null : params.trim();
    }

    /**
     * 获取消耗时间  毫秒
     *
     * @return time_ - 消耗时间  毫秒
     */
    public Long getTime() {
        return time;
    }

    /**
     * 设置消耗时间  毫秒
     *
     * @param time 消耗时间  毫秒
     */
    public void setTime(Long time) {
        this.time = time;
    }

    /**
     * 获取请求者ip地址
     *
     * @return ip_ - 请求者ip地址
     */
    public String getIp() {
        return ip;
    }

    /**
     * 设置请求者ip地址
     *
     * @param ip 请求者ip地址
     */
    public void setIp(String ip) {
        this.ip = ip == null ? null : ip.trim();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Log other = (Log) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getNotes() == null ? other.getNotes() == null : this.getNotes().equals(other.getNotes()))
            && (this.getMethod() == null ? other.getMethod() == null : this.getMethod().equals(other.getMethod()))
            && (this.getRequestUrl() == null ? other.getRequestUrl() == null : this.getRequestUrl().equals(other.getRequestUrl()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getParams() == null ? other.getParams() == null : this.getParams().equals(other.getParams()))
            && (this.getTime() == null ? other.getTime() == null : this.getTime().equals(other.getTime()))
            && (this.getIp() == null ? other.getIp() == null : this.getIp().equals(other.getIp()))
            && (this.getEnable() == null ? other.getEnable() == null : this.getEnable().equals(other.getEnable()))
            && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
            && (this.getCreateBy() == null ? other.getCreateBy() == null : this.getCreateBy().equals(other.getCreateBy()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateBy() == null ? other.getUpdateBy() == null : this.getUpdateBy().equals(other.getUpdateBy()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getNotes() == null) ? 0 : getNotes().hashCode());
        result = prime * result + ((getMethod() == null) ? 0 : getMethod().hashCode());
        result = prime * result + ((getRequestUrl() == null) ? 0 : getRequestUrl().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getParams() == null) ? 0 : getParams().hashCode());
        result = prime * result + ((getTime() == null) ? 0 : getTime().hashCode());
        result = prime * result + ((getIp() == null) ? 0 : getIp().hashCode());
        result = prime * result + ((getEnable() == null) ? 0 : getEnable().hashCode());
        result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
        result = prime * result + ((getCreateBy() == null) ? 0 : getCreateBy().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateBy() == null) ? 0 : getUpdateBy().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", notes=").append(notes);
        sb.append(", method=").append(method);
        sb.append(", requestUrl=").append(requestUrl);
        sb.append(", userId=").append(userId);
        sb.append(", params=").append(params);
        sb.append(", time=").append(time);
        sb.append(", ip=").append(ip);

        sb.append("]");
        return sb.toString();
    }
}